package org.ch02.test00.demo05;

import java.lang.reflect.Method;
import java.util.Scanner;

/**
 * @author CSY
 * @date 2025 - 03 - 19
 */
public class MainTest {
    public static void main(String[] args) throws Exception {
        Scanner sc= new Scanner(System.in);
        Class<?> clazz = sc.getClass();
        Method method = clazz.getMethod("next");
        System.out.print("请输入Email地址：");
        Object obj = method.invoke(sc);
        String email = (String)obj;
        Class<?> strClazz = email.getClass();
        Method indexOfMethod = strClazz.getMethod("indexOf", String.class);
        Integer index = (Integer)indexOfMethod.invoke(email, "@");
        Object substringObj = strClazz.getMethod("substring", int.class, int.class).invoke(email, 0, index);
        System.out.println("账户名："+substringObj);

    }
}
